﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using aspProject.Dmain.Domain;

namespace aspProject.Dmain.DAL
{
    public class CentricContextInitializer : DropCreateDatabaseAlways<CentricEntities>
    {
        protected override void Seed(CentricEntities context)
        {
            //base.Seed(context);

            LabelType a4 = new LabelType()
            {
                Height = 297,
                Width = 210,
                Name = "A4"
            };

            LabelType ietsAnders = new LabelType()
            {
                Height = 5,
                Width = 5,
                Name = "5op5"
            };

            context.LabelTypes.Add(a4);
            context.LabelTypes.Add(ietsAnders);

            context.Users.Add(new User() { Username = "centric", Admin = true, Password = "geheim" });

            context.Products.Add(new Product() { Name = "Tafel", Description = "Een leuke tafel", Price = 20 });
            context.Products.Add(new Product() { Name = "Stoel", Description = "Een leuke stoel", Price = 200 });
            context.Products.Add(new Product() { Name = "Bed", Description = "Een leuk bed", Price = 23 });
            context.Products.Add(new Product() { Name = "Bureau", Description = "Een leuke bureau", Price = 87 });

            List<string> testlijst = new List<string>();
            testlijst.Add("lalala");
            testlijst.Add("jimmy");
            
            DataConfig dataConfig = new DataConfig()
                                  {
                                      Name = "Test",
                                      Databasedata = testlijst
                                  };

            context.DataConfigs.Add(dataConfig);

            List<Component> complijst = new List<Component>();
            complijst.Add(new LabelField()
                              {
                                  Content = "zever",
                                  fontSize = 1,
                                  Height = 2,
                                  positionLeft = 2.0,
                                  PositionTop = 3.0,
                                  text = "zever2",
                                  Width = 0
                              });
            complijst.Add(new LabelField()
            {
                Content = "zever3",
                fontSize = 1,
                Height = 2,
                positionLeft = 2.0,
                PositionTop = 3.0,
                text = "zever4",
                Width = 0
            });

            FieldConfig fieldConfig = new FieldConfig()
                                          {
                                              Components = complijst,
                                              LabelType = a4,
                                              Name = "Niks"
                                          };

            context.FieldConfigs.Add(fieldConfig);
            
            context.SaveChanges();
        }
    }
}
